// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1

package user

import (
	"audio-server/internal/model"
	"context"

	"audio-server/internal/svc"
	"audio-server/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteUserLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeleteUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserLogic {
	return &DeleteUserLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteUserLogic) DeleteUser(req *types.UserDeleteReq) (resp bool, err error) {
	ids := req.Ids
	usersModel := model.NewUsersModel(l.svcCtx.Conn)
	for i := 0; i < len(ids); i++ {
		err = usersModel.Delete(l.ctx, ids[i])
	}
	if err != nil {
		return false, err
	}
	return true, nil
}
